Skip to content

Migrate APOD archive URLs to science.nasa.gov/apod with backward-compatible malformed URL normalization - #86

Draft
oliveratgithub with Copilot wants to merge 3 commits into
masterfrom
copilot/migration-update-apod-website-links
Draft

oliveratgithub with Copilot wants to merge 3 commits into
masterfrom
copilot/migration-update-apod-website-links

Conversation

Copilot AI commented Sep 3, 2026 •

Copy link
Copy Markdown

APOD content links are moving from apod.nasa.gov to science.nasa.gov/apod, and existing URL construction/normalization paths needed updating to avoid broken archive/image links during the migration window. This change updates the base source URL and keeps malformed API URL handling compatible with both old and new APOD host patterns.

  • Configuration

    • Updated NASA_APOD_SOURCE in .env.example to https://science.nasa.gov/apod/.
    • Existing APOD_SOURCE constant usage remains unchanged and now resolves to the new domain via env config.
  • Runtime APOD URL handling

    • Updated APOD malformed URL normalization in public/includes/apod.inc.php to accept both legacy and new APOD prefixes before collapsing to the underlying http... target URL.
    • This preserves behavior for legacy payloads while supporting migrated payloads.
  • Documentation/examples

    • Updated APOD URL examples in README.md and inline APOD response comments to the new domain.
$new_apod_img_small = str_replace(
    ['https://apod.nasa.gov/apod/http', 'https://science.nasa.gov/apod/http'],
    'http',
    $apod_data['url']
);

Copilot AI changed the title [WIP] Update APOD website links for migration Migrate APOD archive URLs to science.nasa.gov/apod with backward-compatible malformed URL normalization Sep 3, 2026
Copilot AI requested a review from oliveratgithub September 3, 2026 06:03
Comment thread public/includes/apod.inc.php Outdated
Comment on lines +92 to +93
$new_apod_img_small = str_replace(['https://apod.nasa.gov/apod/http', 'https://science.nasa.gov/apod/http'], 'http', $apod_data['url']); // with fix for malformed url (APOD API issue)
$new_apod_img_large = str_replace(['https://apod.nasa.gov/apod/http', 'https://science.nasa.gov/apod/http'], 'http', $apod_data['hdurl']); // with fix for malformed url (APOD API issue)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Use The dotENV VAR for the partial part, instead of continuing with a hardcoded full string.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in 981d2be: replaced the hardcoded new-domain prefix in the malformed APOD URL normalization with an APOD_SOURCE-derived prefix (APOD_SOURCE . 'http'), while keeping legacy apod.nasa.gov compatibility.

@oliveratgithub oliveratgithub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot looks like the NASA APOD API changes / changed as well: https://api.nasa.gov/assets/files/apod/APOD-APIs-and-RSS-info.pdf

Analyze the specs in the pdf, and propose required code adjustments in the zorg-code, on top of what was already drafted.

Copilot AI commented Oct 7, 2026

Copy link
Copy Markdown
Author

@copilot looks like the NASA APOD API changes / changed as well: https://api.nasa.gov/assets/files/apod/APOD-APIs-and-RSS-info.pdf

Analyze the specs in the pdf, and propose required code adjustments ...

I reviewed the updated APOD API docs/migration notes and the current get_apod() flow. Proposed follow-up adjustments on top of current PR:

  1. Make response parsing schema-aware (legacy + new):
  • Legacy expects url as media URL.
  • New schema uses url/permalink as post URL and hdurl/thumbnail_url/basic_html for media.
  1. Resolve image source by priority for media_type=image:
  • hdurl (preferred)
  • direct-media url (legacy)
  • fallback from basic_html (og:image or <img src>)
  1. Resolve video/iframe thumbnail by priority:
  • thumbnail_url (new API with thumbs)
  • fallback from basic_html (og:image)
  • fallback to current YouTube/Vimeo-specific logic
  1. Treat media_type=iframe as video-like in switch handling (currently unsupported/default cleanup path).

  2. Add thumbs=true to APOD API requests so video responses include thumbnail URLs when available.

  3. Stop relying only on constructed APOD_SOURCE + apYYMMDD.html for archive links; prefer API-provided permalink when present, fallback to constructed URL for legacy responses.

  4. Update inline docs/examples in apod.inc.php to include new fields (post_id, permalink, basic_html, basic_html_url, optional thumbnail_url) so behavior is explicit.

If you want, I can implement these as a small backward-compatible follow-up commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Migration] Neue NASA APOD Website-Links

2 participants